#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | www.openfoam.com
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
#     Copyright (C) 2012-2016 OpenFOAM Foundation
#     Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
#     etc/config.sh/gperftools
#     Not normally sourced by OpenFOAM-*/etc/bashrc
#
# Description
#     Setup file for GPERFTOOLS binaries/libraries.
#
#     To disable its use:               gperftools_version=gperftools-none
#     For system-wide installations:    gperftools_version=gperftools-system
#
#     For central installations not located under ThirdParty:
#       1. use gperftools-system
#       2. and provide full path for GPERFTOOLS_ARCH_PATH
#
# Note
#     When _foamAddLib is unset (eg, called from makeGperftools):
#       - gperftools_version variable are retained.
#       - the LD_LIBRARY_PATH and PATH are not adjusted.
#
#     No csh version, This file is only used by wmake.
#
#     Can also disable by renaming/removing this file or by creating an empty
#     file with the same name at a user or site location.
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade

gperftools_version=gperftools-2.5
GPERFTOOLS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$gperftools_version

# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
    echo "Using gperftools ($gperftools_version)  ->  $GPERFTOOLS_ARCH_PATH" 1>&2
fi

if command -v _foamAddLib >/dev/null  # Normal sourcing
then

    # If GPERFTOOLS_ARCH_PATH does not end with '-system' or '-none',
    # it is located within ThirdParty, or a central installation
    # outside of ThirdParty and must be added to the lib-path.

    ending="${GPERFTOOLS_ARCH_PATH##*-}"
    if [ "$ending" != none ] && [ "$ending" != system ]
    then
        _foamAddLib     $GPERFTOOLS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
        _foamAddPath    $GPERFTOOLS_ARCH_PATH/bin
    fi

    unset gperftools_version ending

fi

#------------------------------------------------------------------------------
